/*************************************************************
 * 
 * CopyRight(c)2007, http://www.moorwind.com/
 * email:ezhung@gmail.com
 * for free, but a email permission would be nice
 * 
 ************************************************************/
package kono.utils
{
	import kono.utils.collections.List;
	
	//链表栈， linked stack
	public class LinkedStack
	{
		//当前栈顶， current top item
		private var top:List
		
		public function LinkedStack()
		{
			top = new List();
		}
		public function isEmpty():Boolean
		{
			return (top.head == null);
		}
		
		//将给定数据进栈， push the given data into the stack
		public function push(data:*):void
		{
			top.append(data);		
		}
		
		//取得当前栈顶元素， get the top item;
		public function peek():*
		{
			if(top.tail)
				return top.tail.nodeData;
		}
		
		//栈顶数据出栈， remove the top item in the stack
		public function pop():void
		{
			
			top.removeTail();
		}
		
		public function toString():String
		{
			return "[LinkedStack > " + top + "]";
		}
	}
}